package top.majuan.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.majuan.springboot3.base.PageBean;
import top.majuan.springboot3.base.R;
import top.majuan.springboot3.entity.TbClass;
import top.majuan.springboot3.entity.TbSoftwaretype;
import top.majuan.springboot3.service.TbSoftwaretypeService;
import top.majuan.springboot3.vo.PageVo;

import java.util.List;

@RestController
@RequestMapping("/softwaretype")
@RequiredArgsConstructor
public class TbSoftwaretypeController {
    public final TbSoftwaretypeService tbSoftwaretypeService;

    @GetMapping("/queryAll")
    public R<PageVo<TbSoftwaretype>> queryAll(PageBean pageBean, TbSoftwaretype tbSoftwaretype) {
        return tbSoftwaretypeService.queryPage(pageBean, tbSoftwaretype);
    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVo<TbSoftwaretype>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbSoftwaretype tbSoftwaretype) {
        return tbSoftwaretypeService.queryPage(PageBean.instance(pageNumber, pageSize), tbSoftwaretype);
    }

    @PostMapping
    public R<String> insert(@RequestBody TbSoftwaretype tbSoftwaretype) {
        return tbSoftwaretypeService.insert(tbSoftwaretype);
    }
    @GetMapping
    public R<List<TbSoftwaretype>> query(TbSoftwaretype tbSoftwaretype) {
        return tbSoftwaretypeService.query(tbSoftwaretype);
    }
    @GetMapping("/{id}")
    public R<TbSoftwaretype> queryByid(@PathVariable("id") Integer id) {
        return tbSoftwaretypeService.queryByid(id);
    }

    @PutMapping ("")
    public R<String> update(@RequestBody TbSoftwaretype tbSoftwaretype) {
        return tbSoftwaretypeService.update(tbSoftwaretype);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbSoftwaretypeService.delete(id);
    }
}